<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport"
	content="width=device-width, initial-scale=1, maximum-scale=1">
<title>zmall网上商城后台</title>
<link rel="stylesheet" href="css_cz/layui/css/layui.css">
<link rel="stylesheet" href="css_cz/css/global.css">
<link rel="stylesheet" href="css_cz/icheck/minimal/red.css">
</head>
<body>
	<div class="layui-layout layui-layout-admin">
		<!-- 顶部栏和左侧菜单栏 -->
		<jsp:include page="MenuBar.html"></jsp:include>

		<div class="layui-body">
			<!-- 内容主体区域 -->
			<div style="padding: 15px;">
				<fieldset class="layui-elem-field">
					<legend>用户信息</legend>
					<div class="layui-field-box">
						<table class="layui-table">
							<colgroup>
								<col width="150">
								<col width="200">
								<col>
							</colgroup>
							<!-- 表头 -->
							<thead>
								<tr>
									<th>编号</th>
									<th>帐号</th>
									<th>电话</th>
									<th>收货地址</th>
									<th>状态</th>
									<th>操作</th>
								</tr>
							</thead>
							<!-- 表体 -->
							<tbody>
								<!-- 判断接收的list是否为空，是的话 跳转到  BackstageServlet -->
								<c:if test="${list==null}">
									<c:redirect url="BackstageServlet?op=queryalluser"></c:redirect>
								</c:if>
								<c:if test="${list!=null}">
									<c:forEach items="${list}" var="user">
										<tr>
											<td>${user.userid}</td>
											<td>${user.username}</td>
											<td>${user.userphone}</td>
											<td>${user.address}</td>
											<td>${user.userstate}</td>
											<td><a href="#" class="startuser">允许</a> | <a href="#" class="stopuser">禁用</a></td>
										</tr>
									</c:forEach>
								</c:if>
							</tbody>
						</table>
					</div>
				</fieldset>
			</div>
		</div>

		<div class="layui-footer">
			<!-- 底部固定区域 -->
			页脚
		</div>
	</div>
	<script type="text/javascript" src="css_cz/javascript/jquery.min.js"></script>
	<script type="text/javascript" src="css_cz/layui/layui.js"></script>
	<script type="text/javascript" src="css_cz/javascript/index.js"></script>
	<script src="css_cz/layui/layui.js"></script>
	<script>
layui.use(['laypage', 'layer'], function(){
  var laypage = layui.laypage
  ,layer = layui.layer;
  //设置权限 允许
  $(".startuser").click(function(){
	  var username = $(this).parents("tr").find("td").eq(1).text();  
	  $.ajax({
	    	//参数
	    	url: "BackstageServlet",
	    	type: "post",
	    	data:{
	    		username:username,
	    		ustate:"1",
	    		op: "setstate"
	    	},
	    	success: function(res){
				  location.href="http://localhost:8080/ForTheMorning/BackstageServlet?op=queryalluser";	    				  
	    	},
	    	dataType: "json"    	
	    });
	  });
  //设置权限 禁用
  $(".stopuser").click(function(){
	  var username = $(this).parents("tr").find("td").eq(1).text();  
	  $.ajax({
	    	//参数
	    	url: "BackstageServlet",
	    	type: "post",
	    	data:{
	    		username:username,
	    		ustate:"0",
	    		op: "setstate"
	    	},
	    	success: function(res){
				  location.href="http://localhost:8080/ForTheMorning/BackstageServlet?op=queryalluser";	    				  
	    	},
	    	dataType: "json"    	
	    });
	  });
});	
 </script>
</body>
</html>